Using modelflow with World Bank models
Contents
1. Using modelflow with World Bank models¶
The Modelflow python package has been developed to solve a wide range of models, see the modelflow github web site for working examples of the Solow Model, the FR/USB model and others.
The package has been substantially expanded to include special features that enable it to work with World Bank models originally developed in EViews and designed to use EViews Model Object for simuation.
This chapter illustrates how to access these models, how to load them into a modelflow anaconda environment on your computer and how to perform a variety of simulations
1.1. Accessing a world bank model¶
At this time several World bank macrostructural models are available to download and use with modelflow. These include a macrostructural model for:
Indonesia
Nepal
Croatia
Iraq
Kenya
Bolivia
Each of these models has been developed as part of the outreach work of the World Bank. The basic modelling framework of each of these models is outlined in Burns et al. [2019] with specific extensions reflecting features of the individual country modelled.
This book uses as an example a climate aware model for Pakistan developed in 2020 and described in Burns et al. [2021] .
The World Bank models are distributed in the pcim file format of the modelflow and can be downloaded by right clicking on the links above. The Pakistan model can be downloaded here by right clicking on the above link and selecting Save Link as and placing the file on a directory accessible by your modelflow installation.
from worldbankMFModModels import pak
1.2. Preparing your python environment¶
As always, the modelflow and other python packages that will be used need to be imported into your python session. The examples here and this book were written and solved in a Jupyter Notebook. There are some Jupyter specific commands included in these examples and these are annotated. However, the bulk of the content of the programs can be run in other environments, including Interactive Development Environments (IDE) like Spyderor MS Visual Code. All the programs have been tested under spyder as well as Jupyter Notebook.
It is assumed that:
you have already installed
modelflowand its various support packages following the instructions in Chapter xxyou are using Anaconda, and that
you have activated your
modelflowenvironment by executing the following command from your python command line:
conda activate modelflow
where modelflow is the name you have given to the conda environment into which you installed modelflow.
# import the model class from modelflow package
from modelclass import model
import modelmf # Add useful features to pandas dataframes
# using utlities initially developed for modelflow
model.widescreen() # These modelflow commands ensure that outputs from modelflow play well with Jupyter Notebook
model.scroll_off()
%load_ext autoreload
%autoreload 2
2. Working with PakMod under modelflow¶
The basic method for working with any model is the same. Indeed the initial steps followed here are the same as were followed during the simple model discussion.
Process:
Prepare the workspace
Load the model Modelflow
Design some scenarios
Simulate the model
Visualize the results
2.1. Load a pre-existing model, data and descriptions¶
To load a model use the model.modelload() method of modelflow.
The command below
mpak,bline = model.modelload('..\models\pak.pcim', alfa=0.7,run=1,keep= 'Baseline')
instantiates (creates an instance of) a modelflow model object and assigns it to the variable name mpak. The run=1 option executes the model and assigns the result of the model execution to the dataframe bline. The model is solved with the parameter alfa set to 0.7. The \(alfa \in (0,1)\) parameter determines the step size of the solution engine. The larger alfa the larger the step size. Larger step sizes may solve faster, but may have trouble finding a unique solution. Smaller step sizes take longer to solve but are more likely to find a unique solution. Values of alfa=.7 work well for World Bank models.
The keep option instructs modelflow to maintain in the model object (mpak) the results of the initial scenario, assigning it the text name Baseline.
#Replace the path below with the location of the pak.pcim file on your computer
mpak,bline = model.modelload('..\models\pak.pcim', \
alfa=0.7,run=1,keep= 'Baseline')
file read: C:\mflow\modelflow-manual\papers\mfbook\content\models\pak.pcim
Note
the variable bline contains the dataframe with the results of the simulation. This is distinct from the data that is stored by the keep= command. That said, the data associated with each, while stored separately, have the same numerical values. The keep option is described in more detail toward the end of this section.
3. Extracting information about the model¶
The newly loaded python object mpak is an instance of the model class and as such inherits the methods (functions) and properties (data) of that class. To learn about the model there are a variety of methods that can be used to extract information about the model and its data.
A World Bank model in modelflow will contain a wide range of objects.
variables – time series variables comprised of mnemonics and data
dataframes – data for each variable generated in different simulations
groups – lists of variables
equations – identities and behaviourals
model – the model object itself
Extracting information about each of these objects is central to working with WBG models in modelflow.
3.1. Model information¶
The model object contains information about the model itself, its name, its structure (does it contain simultaneous equations or is it recursive), the number of variables it contains and the number that are exogenous and endogenous (have associated equations).
mpak
<
Model name : PAK
Model structure : Simultaneous
Number of variables : 839
Number of exogeneous variables : 461
Number of endogeneous variables : 378
>
The model work space also has a time dimension, its sample period. This can be retrieved and changed.
`mpak.per_current’
mpak.model_description="World Bank climate aware model of Pakistan as described in Burns et al. (2019)"
mpak.model_description
mpak.periode=2100
mpak.
3.2. Information about variables¶
The model object mpak contains lists of all the variables that form part of the model, and these lists can be interrogated to garner information about the model. The Table below indicates some of the most important of these. The variables for which information is sought can be specified directly or through a wildcard specification (see note).
Method |
Example |
Information returned |
|---|---|---|
|
|
returns a python list of the mnemnics of all the variables defined and contained in the model object that match the search paremers in the |
|
|
Dictionary of mnemonics and their variable descriptions |
|
|
List of variable description alone |
|
|
Lists the equation (formula), variable descriptions and variable values |
Note
Wildcards
Most of the information commands accept wildcard specifications in the search parameter.
The * character in the command mpak['PAKNECON*XN'].names example is a wildcard character and the expression will return all variables that begin PAKNECON and end XN.
The ? in the .des example is another wildcard expression. It will match only single characters. Thus mpak['PAKNECONPRVT?N'].names would return three variables: PAKNECONPRVTKN, PAKNECONPRVTXN, and PAKNECONPRVTXN. The real, current value, and deflators for household consumption expenditure.
Note the final show example uses a slightly different syntax where the variable to be operated upon is specified directly: modelname.PAKNECONPRVTXN.show.
The example below returns the mnemonics and descriptions of all variables matching the pattern PAKNYGDP*KN, i.e. Pakistani variables from the National Income Accounts from the main sub-category GDP that are also real variables.
mpak['PAKNYGDP*KN'].des
PAKNYGDPDISCKN : GDP Disc., 2000 LCU mn
PAKNYGDPFCSTKN : GDP Factor Cost Local Currency units Volumes National base year
PAKNYGDPMKTPKN : Real GDP
PAKNYGDPPOTLKN : Potential Output, constant LCU
Box [^BoxWBMnemonics]: World Bank Mnemonics
A typical World Bank model will have in excess of 300 variables. Each has a mnemonic that is structured in a specific way, The root for almost all are 14 characters long (some special variables have additional characters appended to this root) (see discussion in section).
where:
Letters |
Meaning |
|---|---|
\(\color{green}{\texttt{CCC}}\) |
The three-leter ISO code for a country – i.e. IDN for Indonesia, RUS for Russia |
\(\color{red}{\texttt{AA}}\) |
The two-letter major accounting system to which the variable attaches, |
\(\color{lime}{\texttt{MMM}}\) |
The three-letter major sub-category of the data - i.e. GDP, EXP - expenditure |
\(\color{blue}{\texttt{NNNN}}\) |
The four-letter minor sub-category MKTP for market prices |
\(\color{magenta}{\texttt{U}}\) |
The measure (K: real variable;C: Current Values; X: Prices) |
\(\color{black}{\texttt{C}}\) |
denotes the Currency (N: National currency; D: USD; P: PPP) |
Common major accounting systems mnemonics: the, \(\color{red}{\texttt{AA}}\)s from above:
Code |
Meaning |
|---|---|
NY |
National income |
NE |
National expenditure Accounts |
NV |
Value added accounts |
GG |
General Government Accounts |
BX |
Balance of Payments: Exports |
BM |
Balance of Payments: Imports |
BN |
Balance of Payments: Net |
BF |
Balance of Payments: Financial Account |
Thus
Mnemonic |
Meaning |
|---|---|
IDNNYGDPMKTPKN |
Indonesia GDP at market prices, real in Indonesian Rupiah |
KENNECPNPRVTXN |
Kenya Private (household) consumption expenditure schillings deflator |
BOLGGEXPGNFSCN |
Bolivia Government Expenditure on Goods and services (GNFS) in current Bolivars |
HRVGGREVDCITCN |
Croatia Government Revenues Direct Corporate Income Taxes in current Euros |
NPLBXGSRNFSVCD |
Nepal BOP Exports of non-factor services (goods and services) in current USD |
If executed, the command mpak['*'].des would return a dictionary of all the mnemonics and descriptions of all the variables in the mpak model object.
3.2.1. The ! operator – searching on the variable description¶
The same methods can be used to retrieve information about variables, based on their descriptions (vs mnemonic), by pre-pending the search string with the ! operator.
Note
The ! operator If a wildcard is preceded by an exclamation mark ! the search will be done over the description of variables instead of the mnemonic
The below expression returns all variables whose description includes the word Carbon.
mpak['!*Carbon*'].des
PAKGGREVCO2CER : Carbon tax on coal (USD/t)
PAKGGREVCO2GER : Carbon tax on gas (USD/t)
PAKGGREVCO2OER : Carbon tax on oil (USD/t)
3.3. Groups¶
Modelflow inherits a variant of the idea of groups from EViews. In modelflow the groups defined in an imported EViews workfile are converted into entries in a dictionary called var_groups which can be interrogated, added to and amended like any dictionary in python.
The command
mpak.var_groups will return all of the groups already defined in mpak.
mpak.var_groups
{'Headline': '???GDPpckn ???NRTOTLCN ???LMEMPTOTL ???BFFINCABDCD ???BFBOPTOTLCD ???GGBALEXGRCN ???BNCABLOCLCD_ ???FPCPITOTLXN',
'National income accounts': '???NY*',
'National expenditure accounts': '???NE*',
'Value added accounts': '???NV*',
'Balance of payments exports': '???BX*',
'Balance of payments exports and value added ': '???BX* ???NV*',
'Balance of Payments Financial Account': '???BF*',
'General government fiscal accounts': '???GG*',
'World all': 'WLD*',
'PAK all': 'PAK*',
'mylist': 'PAKNECONPRVTKN PAKGGBALOVERLCN'}
A group can be added to the dictionary by giving it a unique identifier (key) and associating with it a string defining the group, using a wildcard specification or just a space de-limited list of mnemonics.
Thus the command
mpak.var_groups['Mygroup]='PAKGGREV*CN PAKGGEBALOVRLCN'
mpak.var_groups['Mygroup']='PAKGGREV*CN PAKGGEBALOVRLCN'
mpak['#Mygroup'].names
['PAKGGREVDRCTCN',
'PAKGGREVEMISCN',
'PAKGGREVGNFSCN',
'PAKGGREVGRNTCN',
'PAKGGREVOTHRCN',
'PAKGGREVTOTLCN',
'PAKGGREVTRDECN']
3.4. Information about data¶
Note the same search functions can be used to display the data associated with the returned variables.
Thus to see the data for the Mygroup group of variables, one could use the .df method or .plot() methods – here modified by pct (to show growth rates) and mul100 to multiply them by 100 to display them as percent change.
mpak['#Mygroup'].pct.mul100.plot()
C:\Users\wb268970\.conda\envs\modelflow\lib\site-packages\IPython\core\pylabtools.py:151: UserWarning: This figure was using constrained_layout, but that is incompatible with subplots_adjust and/or tight_layout; disabling constrained_layout.
fig.canvas.print_figure(bytes_io, **kw)
Below the same logic is used to display the data from variables matching a mnemonic search. The results have been placed inside a with m[pak.set_smpl() clause to restrict the output to a shorter period. If it was not used the output would cover the whole time period of the .lastdf DataFrame from which all of this data is drawm.
with mpak.set_smpl(2020,2030):
print(round(mpak['#Mygroup'].pct.mul100.df,2))
PAKGGREVDRCTCN PAKGGREVEMISCN PAKGGREVGNFSCN PAKGGREVGRNTCN \
2020 13.30 1.10 13.25 39.48
2021 11.69 0.21 11.33 29.52
2022 10.48 0.28 10.11 23.40
2023 9.84 0.82 9.60 19.62
2024 9.48 1.42 9.36 17.09
2025 9.21 1.88 9.18 15.24
2026 8.94 2.14 8.95 13.79
2027 8.67 2.27 8.69 12.61
2028 8.43 2.31 8.43 11.65
2029 8.24 2.34 8.22 10.89
2030 8.11 2.35 8.08 10.31
PAKGGREVOTHRCN PAKGGREVTOTLCN PAKGGREVTRDECN
2020 17.83 16.77 18.25
2021 15.34 14.39 15.28
2022 13.45 12.69 13.71
2023 12.29 11.72 12.89
2024 11.51 11.10 12.35
2025 10.90 10.61 11.87
2026 10.35 10.15 11.38
2027 9.85 9.72 10.90
2028 9.42 9.34 10.46
2029 9.07 9.03 10.08
2030 8.82 8.80 9.76
Jupyter truncates the output by showing the first and last five observations of the active sample period when the same call is made without the with clause.
mpak.smpl(2000,2100)
mpak['#Mygroup'].pct.mul100.df
| PAKGGREVDRCTCN | PAKGGREVEMISCN | PAKGGREVGNFSCN | PAKGGREVGRNTCN | PAKGGREVOTHRCN | PAKGGREVTOTLCN | PAKGGREVTRDECN | |
|---|---|---|---|---|---|---|---|
| 2000 | 9.550328 | 101.829915 | 70.016016 | NaN | NaN | 7.298335 | -21.682305 |
| 2001 | 11.138391 | 15.374786 | 31.458374 | inf | inf | 16.344272 | 5.519481 |
| 2002 | 14.660537 | -13.232471 | 8.545928 | 94.822463 | 17.589007 | 22.839281 | -26.435385 |
| 2003 | 7.111796 | 35.469443 | 17.116998 | -36.962342 | 15.198571 | 6.038960 | 43.955079 |
| 2004 | 8.425066 | 21.635646 | 13.051789 | -39.977372 | 26.297036 | 15.683372 | 32.113024 |
| ... | ... | ... | ... | ... | ... | ... | ... |
| 2096 | 9.025284 | 2.844796 | 9.066803 | 9.025327 | 9.025299 | 9.027988 | 8.957897 |
| 2097 | 9.021221 | 2.842709 | 9.063564 | 9.021258 | 9.021234 | 9.024111 | 8.955230 |
| 2098 | 9.017159 | 2.840601 | 9.060286 | 9.017190 | 9.017170 | 9.020235 | 8.952564 |
| 2099 | 9.013108 | 2.838480 | 9.056979 | 9.013134 | 9.013117 | 9.016371 | 8.949905 |
| 2100 | 9.009075 | 2.836350 | 9.053653 | 9.009098 | 9.009083 | 9.012525 | 8.947260 |
101 rows × 7 columns
3.4.1. Some examples¶
3.4.1.1. .names property¶
mpak['PAKNECON*XN'].names
Return the names (mnemonmics) of all variables that begin PAKNECON and end XN – i.e. Price deflators for various types of consumption demand.
mpak['PAKNECON*XN'].names
['PAKNECONENGYXN', 'PAKNECONGOVTXN', 'PAKNECONOTHRXN', 'PAKNECONPRVTXN']
3.4.1.2. The .des property¶
mpak['PAKNECONPRVT?N'].des
Returns a dictionary comprised of the mnemonics and the descriptions of all the variables that begin PAKNECONPRVT and end N, but have only one character between the T and the N.
mpak['PAKNECONPRVT?N'].des
PAKNECONPRVTCN : Pvt. Cons., LCU mn
PAKNECONPRVTKN : HH. Cons Real
PAKNECONPRVTXN : Implicit LCU defl., Pvt. Cons., 2000 = 1
3.4.2. .var_description method¶
The property .var_descriptionreturns the descriptor of all variables. Modified to a psecifc variable it returns the description of that one variable. This method does not accept wildcards.
#mpak.var_description # returns the descirptions for all variables
mpak.var_description['PAKNYGDPMKTPCN'] # returns the description of a specific variable
'GDP, Market Prices, LCU mn'
mpak.PAKNECONPRVTKN.frml
Endogeneous: PAKNECONPRVTKN: HH. Cons Real
Formular: FRML <DAMP,STOC> PAKNECONPRVTKN = (PAKNECONPRVTKN(-1)*EXP(PAKNECONPRVTKN_A+ (-0.2*(LOG(PAKNECONPRVTKN(-1))-LOG(1.21203101101442)-LOG((((PAKBXFSTREMTCD(-1)-PAKBMFSTREMTCD(-1))*PAKPANUSATLS(-1))+PAKGGEXPTRNSCN(-1)+PAKNYYWBTOTLCN(-1)*(1-PAKGGREVDRCTXN(-1)/100))/PAKNECONPRVTXN(-1)))+0.763938860758873*((LOG((((PAKBXFSTREMTCD-PAKBMFSTREMTCD)*PAKPANUSATLS)+PAKGGEXPTRNSCN+PAKNYYWBTOTLCN*(1-PAKGGREVDRCTXN/100))/PAKNECONPRVTXN))-(LOG((((PAKBXFSTREMTCD(-1)-PAKBMFSTREMTCD(-1))*PAKPANUSATLS(-1))+PAKGGEXPTRNSCN(-1)+PAKNYYWBTOTLCN(-1)*(1-PAKGGREVDRCTXN(-1)/100))/PAKNECONPRVTXN(-1))))-0.0634474791568939*DURING_2009-0.3*(PAKFMLBLPOLYXN/100-((LOG(PAKNECONPRVTXN))-(LOG(PAKNECONPRVTXN(-1)))))) )) * (1-PAKNECONPRVTKN_D)+ PAKNECONPRVTKN_X*PAKNECONPRVTKN_D $
PAKNECONPRVTKN : HH. Cons Real
DURING_2009 :
PAKBMFSTREMTCD : Imp., Remittances (BOP), US$ mn
PAKBXFSTREMTCD : Exp., Remittances (BOP), US$ mn
PAKFMLBLPOLYXN : Key Policy Interest Rate
PAKGGEXPTRNSCN : Current Transfers
PAKGGREVDRCTXN : Direct Revenue Tax Rate
PAKNECONPRVTKN_A: Add factor:HH. Cons Real
PAKNECONPRVTKN_D: Fix dummy:HH. Cons Real
PAKNECONPRVTKN_X: Fix value:HH. Cons Real
PAKNECONPRVTXN : Implicit LCU defl., Pvt. Cons., 2000 = 1
PAKNYYWBTOTLCN : Total Wage Bill
PAKPANUSATLS : Exchange rate LCU / US$ - Pakistan
3.4.3. Information about equations¶
3.4.3.1. The endogene property¶
The endogene property either returns a list of all variables in the model that are endogenous (have an equation). It can also be used to test whether a a specific mnemonic has an equation associated with it.
The expression 'PAKNECONPRVTKN' in mpak.endogene returns True if the passed mnemonic is in the list returned by mpak.endogene.
'PAKNECONPRVTKN' in mpak.endogene
True
3.4.3.2. Retrieving info on equations¶
There are three functions to extract the equations from a model.
Command |
Effect |
|---|---|
|
Returns a normalized version of the equation (the one actually used in modelflow) |
|
In models imported from Eviews, reports the original eviews specification |
|
The equation (formula), variable descriptions variable values |
The equation for consumption in mpak we see that it follows something very close to this formulation.
3.4.3.2.1. The .eviews method¶
The mpak['PAKNECONPRVTKN'].eviews command returns the equations before they were normalized. In most cases this is a slightly more legible form. Here following the EViews syntax, \(\Delta ln()\) is written as dlog().
mpak['PAKNECONPRVTKN'].eviews
PAKNECONPRVTKN : DLOG(PAKNECONPRVTKN) =- 0.2*(LOG(PAKNECONPRVTKN( - 1)) - LOG(1.21203101101442) - LOG((((PAKBXFSTREMTCD( - 1) - PAKBMFSTREMTCD( - 1))*PAKPANUSATLS( - 1)) + PAKGGEXPTRNSCN( - 1) + PAKNYYWBTOTLCN( - 1)*(1 - PAKGGREVDRCTXN( - 1)/100))/PAKNECONPRVTXN( - 1))) + 0.763938860758873*DLOG((((PAKBXFSTREMTCD - PAKBMFSTREMTCD)*PAKPANUSATLS) + PAKGGEXPTRNSCN + PAKNYYWBTOTLCN*(1 - PAKGGREVDRCTXN/100))/PAKNECONPRVTXN) - 0.0634474791568939*@DURING("2009") - 0.3*(PAKFMLBLPOLYXN/100 - DLOG(PAKNECONPRVTXN))
3.4.3.2.2. The .frml method¶
The .frml method returns the normalized equation that is actually used in modelflow. In this instance it is not called for the results of a search operation but by referencing directly the equation (which is itself a property of the mpak model).
Note that following the normalized equation is a listing of all the dependent variables of the equation.
mpak.PAKNECONPRVTKN.frml
Endogeneous: PAKNECONPRVTKN: HH. Cons Real
Formular: FRML <DAMP,STOC> PAKNECONPRVTKN = (PAKNECONPRVTKN(-1)*EXP(PAKNECONPRVTKN_A+ (-0.2*(LOG(PAKNECONPRVTKN(-1))-LOG(1.21203101101442)-LOG((((PAKBXFSTREMTCD(-1)-PAKBMFSTREMTCD(-1))*PAKPANUSATLS(-1))+PAKGGEXPTRNSCN(-1)+PAKNYYWBTOTLCN(-1)*(1-PAKGGREVDRCTXN(-1)/100))/PAKNECONPRVTXN(-1)))+0.763938860758873*((LOG((((PAKBXFSTREMTCD-PAKBMFSTREMTCD)*PAKPANUSATLS)+PAKGGEXPTRNSCN+PAKNYYWBTOTLCN*(1-PAKGGREVDRCTXN/100))/PAKNECONPRVTXN))-(LOG((((PAKBXFSTREMTCD(-1)-PAKBMFSTREMTCD(-1))*PAKPANUSATLS(-1))+PAKGGEXPTRNSCN(-1)+PAKNYYWBTOTLCN(-1)*(1-PAKGGREVDRCTXN(-1)/100))/PAKNECONPRVTXN(-1))))-0.0634474791568939*DURING_2009-0.3*(PAKFMLBLPOLYXN/100-((LOG(PAKNECONPRVTXN))-(LOG(PAKNECONPRVTXN(-1)))))) )) * (1-PAKNECONPRVTKN_D)+ PAKNECONPRVTKN_X*PAKNECONPRVTKN_D $
PAKNECONPRVTKN : HH. Cons Real
DURING_2009 :
PAKBMFSTREMTCD : Imp., Remittances (BOP), US$ mn
PAKBXFSTREMTCD : Exp., Remittances (BOP), US$ mn
PAKFMLBLPOLYXN : Key Policy Interest Rate
PAKGGEXPTRNSCN : Current Transfers
PAKGGREVDRCTXN : Direct Revenue Tax Rate
PAKNECONPRVTKN_A: Add factor:HH. Cons Real
PAKNECONPRVTKN_D: Fix dummy:HH. Cons Real
PAKNECONPRVTKN_X: Fix value:HH. Cons Real
PAKNECONPRVTXN : Implicit LCU defl., Pvt. Cons., 2000 = 1
PAKNYYWBTOTLCN : Total Wage Bill
PAKPANUSATLS : Exchange rate LCU / US$ - Pakistan
3.4.3.2.3. The .show method¶
The .show method returns:
The description of the variable
The normalized equation that is actually used in modelflow.
A listing of the mnemonics and descriptions of the RHS variables
The data of that variable (drawn from the
basedfand.lastdfDataFrames in the model object as well as the data of the RHS variables of the equation from both thebasedfand.lastdfDataFrames.
mpak.smpl(2020,2025) #change the actual sample range to limit the number of columns displayed
mpak.PAKNECONPRVTKN.show
Endogeneous: PAKNECONPRVTKN: HH. Cons Real
Formular: FRML <DAMP,STOC> PAKNECONPRVTKN = (PAKNECONPRVTKN(-1)*EXP(PAKNECONPRVTKN_A+ (-0.2*(LOG(PAKNECONPRVTKN(-1))-LOG(1.21203101101442)-LOG((((PAKBXFSTREMTCD(-1)-PAKBMFSTREMTCD(-1))*PAKPANUSATLS(-1))+PAKGGEXPTRNSCN(-1)+PAKNYYWBTOTLCN(-1)*(1-PAKGGREVDRCTXN(-1)/100))/PAKNECONPRVTXN(-1)))+0.763938860758873*((LOG((((PAKBXFSTREMTCD-PAKBMFSTREMTCD)*PAKPANUSATLS)+PAKGGEXPTRNSCN+PAKNYYWBTOTLCN*(1-PAKGGREVDRCTXN/100))/PAKNECONPRVTXN))-(LOG((((PAKBXFSTREMTCD(-1)-PAKBMFSTREMTCD(-1))*PAKPANUSATLS(-1))+PAKGGEXPTRNSCN(-1)+PAKNYYWBTOTLCN(-1)*(1-PAKGGREVDRCTXN(-1)/100))/PAKNECONPRVTXN(-1))))-0.0634474791568939*DURING_2009-0.3*(PAKFMLBLPOLYXN/100-((LOG(PAKNECONPRVTXN))-(LOG(PAKNECONPRVTXN(-1)))))) )) * (1-PAKNECONPRVTKN_D)+ PAKNECONPRVTKN_X*PAKNECONPRVTKN_D $
PAKNECONPRVTKN : HH. Cons Real
DURING_2009 :
PAKBMFSTREMTCD : Imp., Remittances (BOP), US$ mn
PAKBXFSTREMTCD : Exp., Remittances (BOP), US$ mn
PAKFMLBLPOLYXN : Key Policy Interest Rate
PAKGGEXPTRNSCN : Current Transfers
PAKGGREVDRCTXN : Direct Revenue Tax Rate
PAKNECONPRVTKN_A: Add factor:HH. Cons Real
PAKNECONPRVTKN_D: Fix dummy:HH. Cons Real
PAKNECONPRVTKN_X: Fix value:HH. Cons Real
PAKNECONPRVTXN : Implicit LCU defl., Pvt. Cons., 2000 = 1
PAKNYYWBTOTLCN : Total Wage Bill
PAKPANUSATLS : Exchange rate LCU / US$ - Pakistan
Values :
| 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | |
|---|---|---|---|---|---|---|
| Base | 23,672,888.34 | 23,972,815.36 | 24,164,128.02 | 24,427,863.05 | 24,818,524.47 | 25,323,255.17 |
| Last | 23,672,888.34 | 23,972,815.36 | 24,164,128.02 | 24,427,863.05 | 24,818,524.47 | 25,323,255.17 |
| Diff | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
Input last run:
| 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | |
|---|---|---|---|---|---|---|
| DURING_2009 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKBMFSTREMTCD | 79.99 | 80.28 | 80.17 | 80.09 | 80.24 | 80.72 |
| PAKBMFSTREMTCD(-1) | 79.31 | 79.99 | 80.28 | 80.17 | 80.09 | 80.24 |
| PAKBXFSTREMTCD | 25,608.16 | 28,184.68 | 30,751.54 | 33,417.42 | 36,250.07 | 39,278.43 |
| PAKBXFSTREMTCD(-1) | 23,080.41 | 25,608.16 | 28,184.68 | 30,751.54 | 33,417.42 | 36,250.07 |
| PAKFMLBLPOLYXN | 6.67 | 7.06 | 7.29 | 7.38 | 7.36 | 7.29 |
| PAKGGEXPTRNSCN | 473,448.51 | 515,359.57 | 553,263.89 | 588,831.93 | 623,434.85 | 658,244.15 |
| PAKGGEXPTRNSCN(-1) | 425,736.84 | 473,448.51 | 515,359.57 | 553,263.89 | 588,831.93 | 623,434.85 |
| PAKGGREVDRCTXN | 4.22 | 4.22 | 4.22 | 4.22 | 4.22 | 4.22 |
| PAKGGREVDRCTXN(-1) | 4.22 | 4.22 | 4.22 | 4.22 | 4.22 | 4.22 |
| PAKNECONPRVTKN(-1) | 23,018,638.24 | 23,672,888.34 | 23,972,815.36 | 24,164,128.02 | 24,427,863.05 | 24,818,524.47 |
| PAKNECONPRVTKN_A | 0.01 | 0.00 | 0.00 | -0.00 | -0.00 | -0.00 |
| PAKNECONPRVTKN_D | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKNECONPRVTKN_X | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKNECONPRVTXN | 1.67 | 1.82 | 1.98 | 2.14 | 2.30 | 2.45 |
| PAKNECONPRVTXN(-1) | 1.52 | 1.67 | 1.82 | 1.98 | 2.14 | 2.30 |
| PAKNYYWBTOTLCN | 30,639,578.34 | 33,667,219.15 | 36,907,411.71 | 40,536,234.92 | 44,615,868.39 | 49,126,944.56 |
| PAKNYYWBTOTLCN(-1) | 27,633,148.53 | 30,639,578.34 | 33,667,219.15 | 36,907,411.71 | 40,536,234.92 | 44,615,868.39 |
| PAKPANUSATLS | 107.18 | 107.01 | 106.84 | 106.69 | 106.57 | 106.45 |
| PAKPANUSATLS(-1) | 106.95 | 107.18 | 107.01 | 106.84 | 106.69 | 106.57 |
Input base run:
| 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | |
|---|---|---|---|---|---|---|
| DURING_2009 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKBMFSTREMTCD | 79.99 | 80.28 | 80.17 | 80.09 | 80.24 | 80.72 |
| PAKBMFSTREMTCD(-1) | 79.31 | 79.99 | 80.28 | 80.17 | 80.09 | 80.24 |
| PAKBXFSTREMTCD | 25,608.16 | 28,184.68 | 30,751.54 | 33,417.42 | 36,250.07 | 39,278.43 |
| PAKBXFSTREMTCD(-1) | 23,080.41 | 25,608.16 | 28,184.68 | 30,751.54 | 33,417.42 | 36,250.07 |
| PAKFMLBLPOLYXN | 6.67 | 7.06 | 7.29 | 7.38 | 7.36 | 7.29 |
| PAKGGEXPTRNSCN | 473,448.51 | 515,359.57 | 553,263.89 | 588,831.93 | 623,434.85 | 658,244.15 |
| PAKGGEXPTRNSCN(-1) | 425,736.84 | 473,448.51 | 515,359.57 | 553,263.89 | 588,831.93 | 623,434.85 |
| PAKGGREVDRCTXN | 4.22 | 4.22 | 4.22 | 4.22 | 4.22 | 4.22 |
| PAKGGREVDRCTXN(-1) | 4.22 | 4.22 | 4.22 | 4.22 | 4.22 | 4.22 |
| PAKNECONPRVTKN(-1) | 23,018,638.24 | 23,672,888.34 | 23,972,815.36 | 24,164,128.02 | 24,427,863.05 | 24,818,524.47 |
| PAKNECONPRVTKN_A | 0.01 | 0.00 | 0.00 | -0.00 | -0.00 | -0.00 |
| PAKNECONPRVTKN_D | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKNECONPRVTKN_X | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKNECONPRVTXN | 1.67 | 1.82 | 1.98 | 2.14 | 2.30 | 2.45 |
| PAKNECONPRVTXN(-1) | 1.52 | 1.67 | 1.82 | 1.98 | 2.14 | 2.30 |
| PAKNYYWBTOTLCN | 30,639,578.34 | 33,667,219.15 | 36,907,411.71 | 40,536,234.92 | 44,615,868.39 | 49,126,944.56 |
| PAKNYYWBTOTLCN(-1) | 27,633,148.53 | 30,639,578.34 | 33,667,219.15 | 36,907,411.71 | 40,536,234.92 | 44,615,868.39 |
| PAKPANUSATLS | 107.18 | 107.01 | 106.84 | 106.69 | 106.57 | 106.45 |
| PAKPANUSATLS(-1) | 106.95 | 107.18 | 107.01 | 106.84 | 106.69 | 106.57 |
Difference for input variables
| 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | |
|---|---|---|---|---|---|---|
| DURING_2009 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKBMFSTREMTCD | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKBMFSTREMTCD(-1) | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKBXFSTREMTCD | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKBXFSTREMTCD(-1) | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKFMLBLPOLYXN | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKGGEXPTRNSCN | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKGGEXPTRNSCN(-1) | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKGGREVDRCTXN | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKGGREVDRCTXN(-1) | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKNECONPRVTKN(-1) | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKNECONPRVTKN_A | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKNECONPRVTKN_D | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKNECONPRVTKN_X | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKNECONPRVTXN | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKNECONPRVTXN(-1) | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKNYYWBTOTLCN | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKNYYWBTOTLCN(-1) | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKPANUSATLS | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| PAKPANUSATLS(-1) | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
3.5. Behavioural equations in the MFMod framework¶
Recall a behavioural equation determines the value of an endogenous variable. For many of the variables in Wold Bank models, behavioural functions are estimated using an Error Correction Framework that splits the equation into a theoretically determined long run component and a more idiosyncratic short-run component.
Looking at the eviews representation of the consumption function:
DLOG(PAKNECONPRVTKN) =- 0.2*(LOG(PAKNECONPRVTKN( - 1)) - LOG(1.21203101101442) - LOG((((PAKBXFSTREMTCD( - 1) - PAKBMFSTREMTCD( - 1))*PAKPANUSATLS( - 1)) + PAKGGEXPTRNSCN( - 1) + PAKNYYWBTOTLCN( - 1)*(1 - PAKGGREVDRCTXN( - 1)/100))/PAKNECONPRVTXN( - 1))) + 0.763938860758873*DLOG((((PAKBXFSTREMTCD - PAKBMFSTREMTCD)*PAKPANUSATLS) + PAKGGEXPTRNSCN + PAKNYYWBTOTLCN*(1 - PAKGGREVDRCTXN/100))/PAKNECONPRVTXN) - 0.0634474791568939*@DURING("2009") - 0.3*(PAKFMLBLPOLYXN/100 - DLOG(PAKNECONPRVTXN))
Below the mnemonics are simplified to ease reading of the equation using:
Model Mnemonic |
Simplified |
Meaning |
|---|---|---|
PAKNECONPRVTKN |
\(CON^{KN}_t\) |
Household Consumption |
(PAKBXFSTREMTCD - PAKBMFSTREMTCD)*PAKPANUSATLS |
\(Remit^{net}_t\) |
Net remittances inflows in LCU |
PAKGGEXPTRNSCN |
\(TRANSF^{hhld}_t\) |
Government transfers to households |
DURING_2010 |
\(D^{2010}_t\) |
A dummy |
PAKFMLBLPOLYXN |
\(r^{policy}_t\) |
Policy Rate |
PAKGGREVDRCTXN |
\(DirectTxR_t\) |
Direct Taxes: Effective rate |
PAKNECONPRVTKN_A |
\(CON^{KN_AF}_t\) |
Add factor:Household Consumption |
PAKNECONPRVTXN |
\(CON^{XN}_t\) |
Household Consumption Deflator |
PAKNYYWBTOTLCN |
\(WAGEBILL^{CN}_t\) |
Economy-wide wage bill |
With those substitutions the equation can be rewritten as:
Where in this instance the short-run elasticity of consumption to disposable income is .76 , and the short run elasticity of consumption to the real interest rate is 0.3.
3.5.1. The ECM specification¶
Pretty sure this repeats and earlier section. Delete one
The ECM approach used in World Bank models is described in [Wickens and Breusch, 1988], and addresses the above challenge by modelling both the long run relationship and the short run short run behaviour and brings them together into one equation.
The ECM specification is therefore a single equation comprised of two parts (the long run relationship, and the short-run relationship).
Consider as an example two variables say consumption and disposable income. Both have an underlying trend or in the parlance are co-integrated to degree 1. For simplicity we call them y an x.
3.5.1.1. The short run relationship¶
In its simplest form we might have a short run relationship between the growth rates of our two variables such that:
or substituting lower case letters for the logged values.
3.5.1.2. The long run equation¶
The long run relates the level of the two (or more) variables. A simplified version of that equation can be written as:
Rewriting this (in logarithms) it can be expressed as:
3.5.2. The long run equation in the steady state¶
Note that in the steady state the expected value of the error term in the long run equation is zero (\(\eta_t=0 \)) so in those conditions the long run relationship can be simplified to:
or equivalently (substituting A for the log of \(\alpha\)).
Moreover if this expression is multiplied by some arbitrary constant, say \(-\lambda\), it would still equal zero.
and in the steady state this will also be true for the lagged variables
3.6. Putting it together¶
From before we have the short run equation:
Inserting the steady state expression for the long-run into the short run equation makes no difference (in the long run) because in the long run it is equal to zero.
When the model is not in the steady state the expression \(y_{t-1}-A-βx_{t-1}\) is of course the error term from the long run equation (a measure of how far the dependent variable is from equilibrium).
3.6.1. Lambda, the speed of adjustment¶
The parameter \(\lambda\) can be interpreted as the speed of adjustment. As long as \(\lambda\) is greater than zero and less or equal to one if there are no further disturbances ( \(\epsilon_t=0\)) the expression multiplied by lambda will slowly decline toward zero. How fast depends on how large or small is \(\lambda\).
To be convergent \(\lambda\) must be between 0 and 2, if its is negative or greater than one, then the long run portion of the equation will cause the disequilibrium to grow each period (\(\lambda\) >1) not diminish or if (\(\lambda\) >1<2) output will oscillate from positive to negative (\(\lambda <0\)) but will slowly converge.
Intuitively, the long-run error-term measures how far the model was from equilibrium one period earlier (at t-1). The ECM term (multiplied by \(\lambda\) ensures the model will slowly converge to equilibrium – the point at which the long run equation holds exactly. If \(\lambda\) is greater than zero but less than one (or equal to one) some portion of the previous period year’s disequilibrium will be absorbed each year. How much is absorbed depends on the size of estimated speed of the adjustment coefficient \(\lambda\).
An ECM equation can, therefore be broken into its component parts. For the consumption function it will look something like this: